package com.sphd.restaurantsystem.presenter;


import android.util.Log;

import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.model.FoodInfomationModelImpl;
import com.sphd.restaurantsystem.view.FoodInfomationView;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * Created by Hu on 2016/11/17
 */

public class FoodInfomationPresenterImpl implements FoodInfomationPresenter {
    FoodInfomationModelImpl foodInfomationModel;
    FoodInfomationView foodInfomationView;

    public FoodInfomationPresenterImpl(FoodInfomationView foodInfomationView) {
        this.foodInfomationView = foodInfomationView;
        foodInfomationModel=new FoodInfomationModelImpl();
    }

    @Override
    public void addData(String url) {

    }

    @Override
    public void sendError(VolleyError error) {
        Log.e("ERROR===",error.toString());
    }

    @Override
    public void updata(String url, String image, List<File> fileList, Map<String, String> map) {
        foodInfomationView.showLoading();
        foodInfomationModel.sendUpdata(url,image,fileList,map,this);
    }

    @Override
    public void sendRes(int res) {
        if (res==1){
            foodInfomationView.recSussed();
        }else {
            foodInfomationView.recError();
        }
        foodInfomationView.dissLoading();
    }

    @Override
    public void updataNoImage(String s, Map<String, String> map) {
        foodInfomationView.showLoading();
        foodInfomationModel.sendUpdataNoImage(s,map,this);
    }
}